@extends('public.father')

@section('content')
    @auth()
        <form action="{{route('blog.store')}}" method="post">
            @csrf
            <div class="card">
                <div class="card-header">
                    发布博客
                </div>
                <div class="card-body">
                    <div class="form-group">
                        <label>博客内容</label>
                        <textarea class="form-control" name="content" rows="10"></textarea>
                    </div>

                </div>
                <div class="card-footer text-muted">
                    <button type="submit" class="btn btn-primary">立即发布</button>
                </div>
            </div>
        </form>
    @endauth
    {{--展示所有博客内容--}}
    <div class="card mt-2">
        <div class="card-header">
            博客列表
        </div>
        <div class="card-block">
            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>作者</th>
                    <th>发布时间</th>
                    <th>修改时间</th>
                    <th width="120">操作</th>
                </tr>
                </thead>
                <tbody>
                @foreach($blogs as $v)
                    <tr>
                        <td scope="row">{{$v['id']}}</td>
                        <td>{{$v['uid']}}</td>
                        <td>{{$v['created_at']}}</td>
                        <td>{{$v['updated_at']}}</td>
                        <td>
                            <div class="btn-group" role="group" aria-label="Basic example">
                                <a href="{{route('blog.show',$v)}}" class="btn btn-primary">查看</a>
                                @can('update',$v)
                                    <a href="{{route('blog.edit',$v)}}" class="btn btn-success">编辑</a>
                                @endcan
                                @can('delete',$v)
                                        <form action="{{route('blog.destroy',$v)}}" method="post">
                                            @csrf
                                            @method('DELETE')
                                            <button type="submit" class="btn btn-danger">删除</button>
                                        </form>
                                @endcan
                            </div>
                        </td>
                    </tr>
                @endforeach
                </tbody>
            </table>
        </div>
        <div class="card-footer text-muted">
            {{$blogs->links()}}
        </div>
    </div>
    {{--展示所有博客内容--}}
@endsection
